
package trim.differentmaterials.core.initializers;

import trim.differentmaterials.core.*;
import trim.differentmaterials.coefficients.*;
import trim.differentmaterials.generator.columns.*;

/**
 *
 * @author Podorov Alexander
 */

public class ErlmErnmTrimCoreInitializer extends TrimCoreInitializer
{
    public ErlmErnmTrimCoreInitializer(TrimCore core, Coefficients coefficients)
    {
        super(core, coefficients);
    }

    protected void setInverseMatrix()
    {        
        for (int i = 0; i < materialCount + formatCount; i++)
        {
            inverseMatrix[i][i] = 1.0;
        }
    }

    protected void setRightPart()
    {       
        for (int i = 0; i < formatCount; i++)
        {
            rightPart[i] = formatOrder[i].getCount();
        }
        for (int i = 0; i < materialCount; i++)
        {
            rightPart[i + formatCount] = materialStock[i].getCount();
        }
    }

    protected void setPatterns()
    {
        for (int i = 0; i < formatCount; i++)
        {
            int[] items = new int[materialCount + formatCount];
            items[i] = 1;
            patterns.add(new ArtificialColomn(items, - Double.MAX_VALUE, coefficients.getCoefficient(ArtificialColomn.class), i));
        }
        for (int i = 0; i < materialCount; i++)
        {
            int[] items = new int[materialCount + formatCount];
            items[i + formatCount] = 1;
            patterns.add(new PositiveMaterialGap(items, - Double.MAX_VALUE, coefficients.getCoefficient(PositiveMaterialGap.class), i));
        }
    }
}
